<?php #//v.3.3.0
#///////////////////////////////////////////////////////
#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////

require('./includes/config.inc.php');
       
                      $query_settings = "select * from PHPAUCTIONXL_version_1_3 where id='1'";
                             $query_settings2 =  mysql_query ($query_settings);
                                $closed_auctions2 = mysql_result($query_settings2,0,"closed_auctions");
                                 $closing_auction_note1 = mysql_result($query_settings2,0,"closing_auction_note");
                                       $average_bid_price1 = mysql_result($query_settings2,0,"average_bid_price");
                                       
                if ( empty($closed_auctions2) ) {
                
                 $closed_auctions2 = 6;
                
                }
                
               

$closed_start_limit = ( $closed_page - 1 ) * $closed_auctions2;
$closed_stop_limit = $closed_page * $closed_auctions2;


$closed_auction_header_html ="
<div class=CLOSED_AUCTIONS_BOX_ON > 
<div class=CLOSED_AUCTIONS_BOX_TOP id=liveauctionheader >
<div class=TITLE_BAR_TEXT >

             $CLOSED_AUCTIONS

</div> </div>




  <div class=CLOSED_AUCTION_NOTE  >


  $closing_auction_note1


</div>

";

    



$query = "select ends,id,title,current_high_bidder,current_bid,pict_url,retail,suspended,reserve_price,shipping_fee from PHPAUCTIONXL_auctions
         WHERE closed='1' AND suspended='0' AND current_bid > 0 AND current_bid > reserve_price AND retail > 0 ORDER BY ends DESC LIMIT 0,100";
$result = mysql_query($query);
$num_auction = mysql_num_rows($result);

$i = 0;
$ii = 0;


     if( $num_auction > $closed_auctions2 ) {
$iii = $closed_stop_limit;
 }
 
 if( $num_auction < $closed_auctions2 ) {
$iii = $num_auction;
 }



 if ($closed_start_limit > 1 ) {
$i = $closed_start_limit - 1;
$ii = $closed_start_limit - 1;
$iii = $closed_stop_limit - 1;
}



$closed_auction_boxes_html = "";

while($ii < $iii ) {
         
   $title 	= mysql_result($result,$i,"title");
   $title = stripslashes($title);
	$id 	= mysql_result($result,$i,"id");
	$ends 	= mysql_result($result,$i,"ends");
  $high_bidder 	= mysql_result($result,$i,"current_high_bidder");
	$high_bid 	= mysql_result($result,$i,"current_bid");
	$picture_url = mysql_result($result,$i,"pict_url");      
   $retail = mysql_result($result,$i,"retail");      
      $shipping_fee = mysql_result($result,$i,"shipping_fee");     
                                        
                 
                 
       $query3434 = "select * from PHPAUCTIONXL_bids2 
         WHERE current_high_bidder='$high_bidder' AND auction='$id'";
$result3434 = mysql_query($query3434);
$num_auction3434 = mysql_num_rows($result3434);

   
  $bidcost = $num_auction3434 * $average_bid_price1;   
            
       $high_bid2 = $high_bid + $shipping_fee;     
        /*     echo "[";
             echo $bidcost;
             echo "|";
        echo $high_bid2; 
             echo "|";
        echo  $num_auction3434;
        echo "]"; */
$i++;




$closed_auction_boxes_html .= "<div class=\"CLOSED_AUCTION_ACTIVEBOX\" >\r";

$closed_auction_boxes_html .= "<div class=\"CLOSED_AUCTION_WINNER\">";

$closed_auction_boxes_html .= "$WINNER </div>";

$closed_auction_boxes_html .= "<div class=\"CLOSED_AUCTION_HIGHBIDDER\" >\r";

$closed_auction_boxes_html .= "$high_bidder </div>\r";

$closed_auction_boxes_html .= "<div class=\"CLOSED_AUCTION_SAVINGS\">";

$percentage1 = $high_bid2/$retail;

$percentage2 = $percentage1;

$percentage3 = 100 * (1 - round($percentage2, 2));

$percentage3 .= "%";

$closed_auction_boxes_html .= "$SAVED $percentage3</div>";


  

$closed_auction_boxes_html .= "<div class=\"CLOSED_AUCTION_ITEMPIC\">\r"; 
  

 
$closed_auction_boxes_html .= "  <a href=\"item.php?id=$id\" >\r";

if (file_exists($_SERVER{'DOCUMENT_ROOT'}.'/uploaded/'.$picture_url)) {


$closed_auction_boxes_html .= "  <img src='uploaded/$picture_url' 	alt='$AUCTION_ITEM' border='0' name=\"item_pic$i\" width=100px>\r"; 
 } else {
$closed_auction_boxes_html .= "  \r"; 
}
$closed_auction_boxes_html .= "    </a></div>\r";




$closed_auction_boxes_html .= "<div class=\"CLOSED_AUCTION_TITLE\">\r";

$closed_auction_boxes_html .= "  <a class=LIVE_TITLE_LINKS href=\"item.php?id=$id\" id=\"href$i\">\r";

$closed_auction_boxes_html .= " $title   </a></div>\r";

$closed_auction_boxes_html .= "</div> \r";


 $ii++;
 
 if( $ii != $iii ) {

$closed_auction_boxes_html .= "<div class=\"CLOSED_AUCTION_VERTICAL_LINE\" >\r";

 $closed_auction_boxes_html .= "</div> \r";
   }
 
 
 

  
         }
         
         
         
  
         
  
$closed_auction_bottom_html = "  
      <div class=PAGE_PAGINATION_BOX_ON style=\"margin-top:40px;\">  $pagination_closed</div>
</div>      
<div class=CLOSED_AUCTIONS_BOX_BOTTOM id=closedauctionbottom>
</div>";  
   
     echo $closed_auction_header_html; 
      echo     $closed_auction_boxes_html;
   echo $closed_auction_bottom_html;
  // echo $closed_auctions2;
  //echo $closed_start_limit;
  //echo $closed_stop_limit;
   ?>   